﻿using System;
using UnityEngine;

// Token: 0x0200006D RID: 109
public class GuideDrive_PosEasy : GuideDrive_Pos
{
	// Token: 0x06000383 RID: 899 RVA: 0x00016398 File Offset: 0x00014598
	private void Start()
	{
		base.Init();
	}

	// Token: 0x06000384 RID: 900 RVA: 0x000163A0 File Offset: 0x000145A0
	private void Update()
	{
		if (this.onMove)
		{
			Vector3 move = this.PlanePos(Input.mousePosition) - this.PlanePos(this.movePrevPos);
			this.movePrevPos = Input.mousePosition;
			this.manager.DriveMovePosition(move);
			if (Input.GetMouseButtonUp(0))
			{
				this.OnMoveEnd();
				this.manager.OnMoveEnd(this);
			}
		}
	}

	// Token: 0x06000385 RID: 901 RVA: 0x0001640C File Offset: 0x0001460C
	public override void OnMoveStart(Vector3 clickPos)
	{
		base.OnMoveStart(clickPos);
		Vector3 rhs = Camera.main.transform.rotation * Vector3.forward;
		Quaternion rotation = Quaternion.Euler(0f, Camera.main.transform.rotation.eulerAngles.y, 0f);
		float num = Mathf.Abs(Vector3.Dot(rotation * Vector3.forward, rhs));
		float num2 = Mathf.Abs(Vector3.Dot(rotation * Vector3.up, rhs));
		float num3 = Mathf.Abs(Vector3.Dot(rotation * Vector3.right, rhs));
		if (num >= num2 && num >= num3)
		{
			this.moveType = GuideDrive_Pos.MoveType.XY;
			this.dir = rotation * Vector3.forward;
		}
		else if (num2 >= num && num2 >= num3)
		{
			this.moveType = GuideDrive_Pos.MoveType.XZ;
			this.dir = rotation * Vector3.up;
		}
		else
		{
			this.moveType = GuideDrive_Pos.MoveType.YZ;
			this.dir = rotation * Vector3.right;
		}
	}

	// Token: 0x06000386 RID: 902 RVA: 0x00016524 File Offset: 0x00014724
	private Vector3 PlanePos(Vector3 screenPos)
	{
		Vector3 inNormal = base.transform.rotation * this.dir;
		Plane plane = new Plane(inNormal, base.transform.position);
		Ray ray = Camera.main.ScreenPointToRay(screenPos);
		float distance = 0f;
		if (plane.Raycast(ray, out distance))
		{
			return ray.GetPoint(distance);
		}
		return this.manager.transform.position;
	}

	// Token: 0x04000317 RID: 791
	private Vector3 dir;
}
